package com.hsc.www.oschina;


public class WebResponse {

    private final static Integer CODE_SUCCESS = 1;
    private final static String MSG_SUCCESS = "成功";
    private final static Integer CODE_FAILURE = 0;
    private final static String MSG_FAILURE = "失败";

    private Integer code;
    private String msg;
    private Object data;


    public static WebResponse success() {
        return success(null);
    }

    public static WebResponse success(Object data) {
        return create(CODE_SUCCESS, MSG_SUCCESS, data);
    }

    public static WebResponse failure() {
        return failure(null);
    }

    public static WebResponse failure(String msg) {
        return failure(msg, null);
    }

    public static WebResponse failure(Object data) {
        return failure(MSG_FAILURE, data);
    }

    public static WebResponse failure(String msg, Object data) {
        return create(CODE_FAILURE, msg, data);
    }


    public static WebResponse create(Integer code, String msg, Object data) {
        WebResponse webResponse = new WebResponse();
        webResponse.setCode(code);
        webResponse.setMsg(msg);
        webResponse.setData(data);
        return webResponse;
    }



    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }



}
